package org.mobile.beans;

import javax.faces.component.html.HtmlCommandButton;
import javax.faces.component.html.HtmlSelectBooleanCheckbox;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;

public class RegisterBean {
	    private HtmlSelectBooleanCheckbox checkbox;
	    private HtmlCommandButton submitButton;

	    public RegisterBean(){
	        submitButton = new HtmlCommandButton();
	        submitButton.setDisabled(true);
	    }

	    public HtmlSelectBooleanCheckbox getCheckbox() {
	        return checkbox;
	    }

	    public void setCheckbox(HtmlSelectBooleanCheckbox checkbox) {
	        this.checkbox = checkbox;
	    }

	    public HtmlCommandButton getSubmitButton() {
	        return submitButton;
	    }

	    public void setSubmitButton(HtmlCommandButton submitButton) {
	        this.submitButton = submitButton;
	    }

	    public void checkboxOnChange(ValueChangeEvent valueChangeEvent){
	        if(checkbox.isSelected()) {
	            submitButton.setDisabled(false);
	        }
	        else {
	            submitButton.setDisabled(true);
	        }
	        FacesContext context = FacesContext.getCurrentInstance();
	        context.renderResponse();
	    }

}
